package com.py.credit.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.py.credit.entity.TableResult;
import com.py.credit.entity.ViewInfo;
import com.py.credit.entity.common.OptionalColumn;
import com.py.framework.core.common.Page;

public interface ViewInfoDao {

	void add(ViewInfo viewInfo);

	/**
	 * @param kId
	 * @param showColumns
	 * @param additioanlColumns
	 * @param conditions
	 * @param page
	 * @return
	 */
	List<Map<String, Object>> selectTableListByConditionForPage(@Param(value = "rootId") String kId,
			@Param(value = "columns") List<String> showColumns,
			@Param(value = "additionalColumns") String[] additioanlColumns,
			@Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page);

	/**
	 * @param tableResult
	 */
	// void addViewColumn(@Param(value = "list") TableResult tableResult,
	// @Param(value = "viewId") int viewId);

	/**
	 * @param viewId
	 * @return
	 */
	List<OptionalColumn> selectViewResultOptionalColums(@Param(value = "viewId") String viewId);

	/**
	 * @param viewId
	 * @return
	 */
	List<OptionalColumn> selectViewResultAdvancedConditionColumns(@Param(value = "viewId") String viewId);

	/**
	 * @param viewId
	 * @param showColumns
	 * @param additioanlColumns
	 * @param condition
	 * @param page
	 * @return
	 */
	List<Map<String, Object>> selectViewResultByConditionForPage(@Param(value = "viewName") String viewName,
			@Param(value = "columns") List<String> showColumns,
			@Param(value = "additionalColumns") String[] additioanlColumns,
			@Param(value = "conditions") List<String> condition, @Param(value = "page") Page page);

	/**
	 * @param viewId
	 * @return
	 */
	List<String> selectDefaultShowColumnEN(@Param(value = "viewId") String viewId);

	/**
	 * @param name
	 * @param integer
	 * @return
	 */
	int selectByViewName(@Param(value = "name") String name, @Param(value = "viewId") Integer viewId);

	/**
	 * @param ids
	 */
	void delView(@Param(value = "list") String[] ids);

	/**
	 * @param ids
	 */
	void delViewMetric(@Param(value = "list") String[] ids);

	void dropView(@Param(value = "name") String name);

	List<String> selectViewNameByIds(@Param(value = "list") String[] ids);

	/**
	 * @param viewId
	 * @return
	 */
	List<TableResult> selectDetail(@Param(value = "id") String viewId);

	/**
	 * @param tableNameCN
	 * @param tableNameEN
	 * @param aliases
	 * @param metricId
	 * @param metricCode
	 * @param metricName
	 * @param id
	 */
	void addViewColumn(@Param(value = "tableNameCN") String tableNameCN,
			@Param(value = "tableNameEN") String tableNameEN, @Param(value = "aliases") String aliases,
			@Param(value = "metricId") Integer metricId, @Param(value = "metricCode") String metricCode,
			@Param(value = "metricName") String metricName, @Param(value = "viewId") Integer id);

	/**
	 * @param viewInfo
	 */
	void update(ViewInfo viewInfo);

	/**
	 * @param viewId
	 * @return
	 */
	ViewInfo selectViewInfoById(@Param(value = "id") String viewId);
}